<?php

/**
 * view actions.
 *
 * @package    raidpoints
 * @subpackage view
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class jsActions extends sfActions
{
    public function executeLoad(sfWebRequest $request)
    {
        $filename = $request->getParameter('filename');
        $name = $request->getParameter('name');

        if ($filename == "filter")
        {
            $query = Doctrine::getTable("Filter")
                    ->createQuery('f')
                    ->orderBy("sort")
                    ->leftJoin("f.FilterTalent ft")
                    ->leftJoin("f.FilterClass fc")
                    ->leftJoin("ft.Talent ftt")
                    ->leftJoin("ftt.PClass fttc")
                    ->leftJoin("fc.PClass fcc");
            $filters = $query->execute();

            $query = Doctrine::getTable("Rank")
                    ->createQuery('f')
                    ->orderBy("sort");
            $result = $query->execute();

            $ranks = array();
            foreach ($result as $rank)
            {
                $ranks[$rank['name']] = $rank['name'];
            }

            $this->getContext()->getConfiguration()->loadHelpers('Partial');
            return $this->renderText(get_partial('js/'.$filename,
                    array(
                    'name' => $name,
                    'id' => 'filterDialog',
                    'filters' => $filters,
                    'ranks' => $ranks
                    )
                    )
            );
        }
        else
        {
            $this->getContext()->getConfiguration()->loadHelpers('Partial');
            return $this->renderText(get_partial('js/'.$filename,
                    array(
                    'name' => $name,
                    )
                    )
            );
        }
    }
}
